import QtQuick 2.6
import QtQuick.Layouts 1.2

import "../../Base/UiBase"
import "../../Base/Config"

Item {

    function getModel(communityId)
    {
        return testModel;
    }

    ColumnLayout {
        anchors.fill: parent
        spacing: Size.elementInterval
        Nav {
            id: nav
            Layout.fillWidth: true
            Layout.preferredHeight: height
        }
        Item {
            Layout.fillWidth: true
            Layout.fillHeight: true
            z: -1

            Loader {
                id:communityLoader
                parent: tcIndex
                anchors.fill: parent
            }
            Component {
                id:communityComponent
                Community {
                }
            }

            ListView {
                id: postHolderParent

                anchors.fill: parent
                spacing: Size.elementInterval

                delegate: MouseArea {
                    onClicked: {
                        communityLoader.sourceComponent = communityComponent
                        communityLoader.item.head = model.head
                        communityLoader.item.name = model.name
                        communityLoader.item.description = model.description
                        communityLoader.item.nfocus = model.nfocus
                        communityLoader.item.nactive = model.nactive
                    }

                    width: parent.width
                    height: 140 * Size.ratio
                    Rectangle {
                        anchors.fill: parent
                        color: Color.foreground
                    }

                    RowLayout {
                        anchors.fill: parent
                        spacing:0
                        Item {
                            Layout.preferredWidth: 140 * Size.ratio
                            Layout.preferredHeight: 140 * Size.ratio
                            HeadHolder {
                                anchors.centerIn: parent
                                SvgzImage {
                                    width: 120 * Size.ratio
                                    height: 120 * Size.ratio
                                    source: model.head
                                }
                            }
                        }
                        ColumnLayout {
                            Layout.fillWidth: true
                            Layout.fillHeight: true
                            Layout.rightMargin: 20
                            Text {
                                verticalAlignment: Text.AlignVCenter
                                Layout.fillWidth: true
                                Layout.fillHeight: true
                                text: model.name
                                font.pixelSize: Size.font26
                                color: Color.input
                            }
                            Text {
                                verticalAlignment: Text.AlignVCenter
                                Layout.fillWidth: true
                                Layout.fillHeight: true
                                text: model.description
                                font.pixelSize: Size.font26
                                color: Color.virtualInput
                            }
                            Text {
                                verticalAlignment: Text.AlignVCenter
                                Layout.fillWidth: true
                                Layout.fillHeight: true
                                text: model.nfocus
                                font.pixelSize: Size.font26
                                color: Color.virtualInput
                                Text {
                                    verticalAlignment: Text.AlignVCenter
                                    anchors.left : parent.left
                                    anchors.leftMargin: 200 * Size.ratio
                                    text: model.nactive
                                    font.pixelSize: Size.font26
                                    color: Color.virtualInput
                                }
                            }
                        }
                    }
                }
                model:getModel(nav.page)
            }
        }
    }

    ListModel {
        id:testModel
        ListElement {
            head: "../../../resources/tests/c50f525bjw1eh9zber5uij20c80hb3zw.jpg"
            name: "name"
            description: "description"
            nfocus: 1000
            nactive: 1000
        }
        ListElement {
            head: "../../../resources/tests/69b7d63agw1ex95lh4eatj20c80godhc.jpg"
            name: "name"
            description: "description"
            nfocus: 1000
            nactive: 1000
        }
        ListElement {
            head: "../../../resources/tests/355X400.jpg"
            name: "name"
            description: "description"
            nfocus: 1000
            nactive: 1000
        }
    }
}
